package com.Cychat.post.mapper;


import com.Cychat.commons.entity.pojo.Favorite;
import com.Cychat.post.entity.dto.FavoriteDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Auther: 崔航
 * @Date: 2025/11/3:11:53
 * @Description:
 */
@Mapper
public interface FavoriteMapper extends BaseMapper<Favorite> {
@Select("SELECT * FROM favorite f JOIN post p ON f.target_id = p.post_id " +
        "JOIN user u ON p.user_id = u.user_id " +
        "WHERE f.user_id = #{userId} AND f.type = 'post'")
    List<FavoriteDTO> selectPostFavorites(Long userId);
@Delete("DELETE FROM favorite WHERE user_id = #{userId} AND target_id = #{targetId}")
    void deleteFavorite(@Param("userId") Long userId, @Param("targetId") Integer targetId);
}
